<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>prencar: D:/Workspace/Arduino/prencar/Communication.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="prencar.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">prencar
   &#160;<span id="projectnumber">1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_communication_8cpp.html','');
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/Workspace/Arduino/prencar/Communication.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_communication_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="_communication_8h.html">Communication.h</a>&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="_configuration_8h.html">Configuration.h</a>&quot;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;<a class="code" href="_command_8h.html">Command.h</a>&quot;</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <a class="code" href="class_communication.html">Communication</a> <a class="code" href="class_communication.html#ab0959d51f9cb9ee0ea2547b74856f283" title="Static reference to the singleton object.">Communication::_instance</a>; 
<a name="l00006"></a>00006 <span class="keywordtype">boolean</span> <a class="code" href="class_communication.html#ad7d224755b1c47a1b5e6ce0d018492bb">Communication::_instanceCreated</a> = <span class="keyword">false</span>;
<a name="l00007"></a>00007 
<a name="l00008"></a><a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">00008</a> <span class="preprocessor">#define sc Serial</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span>
<a name="l00014"></a><a class="code" href="class_communication.html#ad7b13fccf78bfce83efc9bb06c64facd">00014</a> <a class="code" href="class_communication.html">Communication</a>* <a class="code" href="class_communication.html#ad7b13fccf78bfce83efc9bb06c64facd">Communication::getInstance</a>()
<a name="l00015"></a>00015 {
<a name="l00016"></a>00016   <span class="keywordflow">if</span> ( !<a class="code" href="class_communication.html#ad7d224755b1c47a1b5e6ce0d018492bb">_instanceCreated</a> ){
<a name="l00017"></a>00017     <a class="code" href="class_communication.html#ab0959d51f9cb9ee0ea2547b74856f283" title="Static reference to the singleton object.">_instance</a> = <a class="code" href="class_communication.html#a88aa7a2d2ac5202e2b8eef787d1a8689">Communication</a>();
<a name="l00018"></a>00018     <a class="code" href="class_communication.html#ad7d224755b1c47a1b5e6ce0d018492bb">_instanceCreated</a> = <span class="keyword">true</span>;
<a name="l00019"></a>00019   }
<a name="l00020"></a>00020   <span class="keywordflow">return</span> &amp;<a class="code" href="class_communication.html#ab0959d51f9cb9ee0ea2547b74856f283" title="Static reference to the singleton object.">_instance</a>;
<a name="l00021"></a>00021 }
<a name="l00025"></a><a class="code" href="class_communication.html#a88aa7a2d2ac5202e2b8eef787d1a8689">00025</a> <a class="code" href="class_communication.html#a88aa7a2d2ac5202e2b8eef787d1a8689">Communication::Communication</a>(){
<a name="l00026"></a>00026   <span class="comment">//get a reference to the configuration</span>
<a name="l00027"></a>00027   <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a> = <a class="code" href="class_communication.html#ad7b13fccf78bfce83efc9bb06c64facd">Configuration::getInstance</a>();
<a name="l00028"></a>00028 
<a name="l00029"></a>00029   <a class="code" href="class_communication.html#acfaf4176401e364e3b0476a6eb220817" title="The position of the last character in the buffer (lastBufferChar + 1 will be the next empty spot)...">_lastBufferCharacter</a> = 0;
<a name="l00030"></a>00030 
<a name="l00031"></a>00031   <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.begin(<a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#aab8a109a9db934c027b08c0ccbb83066">getSerialSpeed</a>());
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033 
<a name="l00040"></a><a class="code" href="class_communication.html#ab405d4412e7f2515e4fdc2e61a8d5963">00040</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#ab405d4412e7f2515e4fdc2e61a8d5963">Communication::doJob</a>(){
<a name="l00041"></a>00041   <span class="keywordtype">int</span> amountAvailableBytes = <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.available();
<a name="l00042"></a>00042   <span class="keywordflow">while</span>(amountAvailableBytes &gt; 0){
<a name="l00043"></a>00043     <a class="code" href="class_communication.html#a55d359c2e8b6061388edbf07aa42c385" title="Buffer to store ONE incoming line which is not yet completely transmitted.">_incomingDataBuffer</a>[<a class="code" href="class_communication.html#acfaf4176401e364e3b0476a6eb220817" title="The position of the last character in the buffer (lastBufferChar + 1 will be the next empty spot)...">_lastBufferCharacter</a>] = <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.read();
<a name="l00044"></a>00044     <span class="comment">//if one line is completely transmitted create a command</span>
<a name="l00045"></a>00045     <span class="keywordflow">if</span>(<a class="code" href="class_communication.html#a55d359c2e8b6061388edbf07aa42c385" title="Buffer to store ONE incoming line which is not yet completely transmitted.">_incomingDataBuffer</a>[<a class="code" href="class_communication.html#acfaf4176401e364e3b0476a6eb220817" title="The position of the last character in the buffer (lastBufferChar + 1 will be the next empty spot)...">_lastBufferCharacter</a>] == <span class="charliteral">&#39;\n&#39;</span>){
<a name="l00046"></a>00046       <a class="code" href="class_communication.html#ad566d07485df1c7970edd450723da1aa">parseAndPutCommandOnList</a>(<a class="code" href="class_communication.html#a55d359c2e8b6061388edbf07aa42c385" title="Buffer to store ONE incoming line which is not yet completely transmitted.">_incomingDataBuffer</a>);
<a name="l00047"></a>00047       <a class="code" href="class_communication.html#acfaf4176401e364e3b0476a6eb220817" title="The position of the last character in the buffer (lastBufferChar + 1 will be the next empty spot)...">_lastBufferCharacter</a> = -1;
<a name="l00048"></a>00048     }
<a name="l00049"></a>00049     <a class="code" href="class_communication.html#acfaf4176401e364e3b0476a6eb220817" title="The position of the last character in the buffer (lastBufferChar + 1 will be the next empty spot)...">_lastBufferCharacter</a>++;
<a name="l00050"></a>00050     amountAvailableBytes--;
<a name="l00051"></a>00051   }
<a name="l00052"></a>00052 
<a name="l00053"></a>00053   <a class="code" href="class_communication.html#a43c8f2812f29ab78f7213838e715cf49">checkCommands</a>();
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00059"></a><a class="code" href="class_communication.html#ad566d07485df1c7970edd450723da1aa">00059</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#ad566d07485df1c7970edd450723da1aa">Communication::parseAndPutCommandOnList</a>(byte* commandString){
<a name="l00060"></a>00060   <span class="comment">//find the first free spot</span>
<a name="l00061"></a>00061   <span class="keywordtype">int</span> i;
<a name="l00062"></a>00062   <span class="keywordtype">boolean</span> spotFound = <span class="keyword">false</span>;
<a name="l00063"></a>00063   <span class="keywordflow">for</span>(i = 0; i &lt; <a class="code" href="class_communication.html#a9c8bdd0590074d523a055e50284f5ce1" title="The amount of commands that can be stored into the readyCommands array.">_READYCOMMANDSSIZE</a>; i++){
<a name="l00064"></a>00064     <span class="keywordflow">if</span>(<a class="code" href="class_communication.html#a7614d37dd498c0c4549d36d88eb39c24" title="Holds all the commands that are ready for execution.">readyCommands</a>[i].commandCode == 0){
<a name="l00065"></a>00065       spotFound = <span class="keyword">true</span>;
<a name="l00066"></a>00066       <span class="keywordflow">break</span>;
<a name="l00067"></a>00067     } 
<a name="l00068"></a>00068   }
<a name="l00069"></a>00069   <span class="keywordflow">if</span>(spotFound == <span class="keyword">false</span>){
<a name="l00070"></a>00070     <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(150);
<a name="l00071"></a>00071     <span class="keywordflow">return</span>;
<a name="l00072"></a>00072   }
<a name="l00073"></a>00073   <a class="code" href="class_command.html" title="A Command object represents a command sent from the host software.">Command</a> c;
<a name="l00074"></a>00074   c.<a class="code" href="class_command.html#adbc9f2539741be419397502840f3740c">parse</a>(commandString);
<a name="l00075"></a>00075 
<a name="l00076"></a>00076   <a class="code" href="class_communication.html#a7614d37dd498c0c4549d36d88eb39c24" title="Holds all the commands that are ready for execution.">readyCommands</a>[i] = c;
<a name="l00077"></a>00077 
<a name="l00078"></a>00078   <span class="keywordtype">int</span> parameters[3];
<a name="l00079"></a>00079   parameters[0] = c.<a class="code" href="class_command.html#a31842ee183ae2cd06ce6ad8f7533ff02">commandCode</a>;
<a name="l00080"></a>00080   parameters[1] = i;
<a name="l00081"></a>00081   parameters[2] = <a class="code" href="class_communication.html#a9c8bdd0590074d523a055e50284f5ce1" title="The amount of commands that can be stored into the readyCommands array.">_READYCOMMANDSSIZE</a>;
<a name="l00082"></a>00082   <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(61, parameters, 3);
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00088"></a><a class="code" href="class_communication.html#a43c8f2812f29ab78f7213838e715cf49">00088</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a43c8f2812f29ab78f7213838e715cf49">Communication::checkCommands</a>(){
<a name="l00089"></a>00089   <a class="code" href="class_command.html" title="A Command object represents a command sent from the host software.">Command</a> c;
<a name="l00090"></a>00090 
<a name="l00091"></a>00091   <span class="comment">//check for command 100</span>
<a name="l00092"></a>00092   <span class="keywordflow">if</span>(<a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">getAndRemoveCommandFromReadyCommands</a>(&amp;c, 100)){
<a name="l00093"></a>00093     <a class="code" href="class_communication.html#a17e42ee6dbbaa353944d63e7d5dee25a">sendCurrentConfiguration</a>();
<a name="l00094"></a>00094   }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097 
<a name="l00106"></a><a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">00106</a> <span class="keywordtype">boolean</span> <a class="code" href="class_communication.html#a17bff838a0404ae06482f17bcecd3784">Communication::getAndRemoveCommandFromReadyCommands</a>(<a class="code" href="class_command.html" title="A Command object represents a command sent from the host software.">Command</a>* c, <span class="keywordtype">int</span> commandCode){
<a name="l00107"></a>00107   <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="class_communication.html#a9c8bdd0590074d523a055e50284f5ce1" title="The amount of commands that can be stored into the readyCommands array.">_READYCOMMANDSSIZE</a>; i++){
<a name="l00108"></a>00108     <span class="keywordflow">if</span>(<a class="code" href="class_communication.html#a7614d37dd498c0c4549d36d88eb39c24" title="Holds all the commands that are ready for execution.">readyCommands</a>[i].commandCode == commandCode){
<a name="l00109"></a>00109       *c = <a class="code" href="class_communication.html#a7614d37dd498c0c4549d36d88eb39c24" title="Holds all the commands that are ready for execution.">readyCommands</a>[i];
<a name="l00110"></a>00110       
<a name="l00111"></a>00111       <span class="comment">//remove command from the list</span>
<a name="l00112"></a>00112       <a class="code" href="class_communication.html#a7614d37dd498c0c4549d36d88eb39c24" title="Holds all the commands that are ready for execution.">readyCommands</a>[i].<a class="code" href="class_command.html#a31842ee183ae2cd06ce6ad8f7533ff02">commandCode</a> = 0;
<a name="l00113"></a>00113       
<a name="l00114"></a>00114       <span class="keywordtype">int</span> parameters[3];
<a name="l00115"></a>00115       parameters[0] = c-&gt;<a class="code" href="class_command.html#a31842ee183ae2cd06ce6ad8f7533ff02">commandCode</a>;
<a name="l00116"></a>00116       parameters[1] = i;
<a name="l00117"></a>00117       <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(62, parameters, 2);
<a name="l00118"></a>00118       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00119"></a>00119     } 
<a name="l00120"></a>00120   }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122   <span class="comment">//if the command was not found set the commandCode of the given object to 0</span>
<a name="l00123"></a>00123   c-&gt;<a class="code" href="class_command.html#a31842ee183ae2cd06ce6ad8f7533ff02">commandCode</a> = 0;
<a name="l00124"></a>00124   <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00133"></a><a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">00133</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">Communication::send</a>(byte messageId){
<a name="l00134"></a>00134   <span class="keywordflow">if</span>(messageId &gt; <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#ad398e1915b07ffc4091d4d5827bd6c6e">getMessageFilterLevel</a>()){
<a name="l00135"></a>00135     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.println(messageId);
<a name="l00136"></a>00136   }
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00144"></a><a class="code" href="class_communication.html#ae69fab10af713fa7eef7b75ee804d030">00144</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">Communication::send</a>(byte messageId, <span class="keywordtype">int</span> param){
<a name="l00145"></a>00145   <span class="keywordflow">if</span>(messageId &gt; <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#ad398e1915b07ffc4091d4d5827bd6c6e">getMessageFilterLevel</a>()){
<a name="l00146"></a>00146     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(messageId);
<a name="l00147"></a>00147     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;:&quot;</span>);
<a name="l00148"></a>00148     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.println(param);
<a name="l00149"></a>00149   }
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 
<a name="l00162"></a><a class="code" href="class_communication.html#a4f3943a64cf5fb3e28c343582bedb80a">00162</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">Communication::send</a>(byte messageId, <span class="keyword">const</span> <span class="keywordtype">long</span> params[], byte paramSize){
<a name="l00163"></a>00163   <span class="keywordflow">if</span>(messageId &gt; <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#ad398e1915b07ffc4091d4d5827bd6c6e">getMessageFilterLevel</a>()){
<a name="l00164"></a>00164     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(messageId);
<a name="l00165"></a>00165     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;-&quot;</span>);
<a name="l00166"></a>00166     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(paramSize);
<a name="l00167"></a>00167     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;:&quot;</span>);
<a name="l00168"></a>00168     byte i;
<a name="l00169"></a>00169     <span class="keywordflow">for</span>(i = 0; i &lt; (paramSize - 1); i++){
<a name="l00171"></a>00171       <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(params[i], DEC);
<a name="l00172"></a>00172       <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;,&quot;</span>);
<a name="l00173"></a>00173     }
<a name="l00174"></a>00174     <span class="comment">//the last one is sent without a comma but with a new line</span>
<a name="l00175"></a>00175     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.println(params[i]);
<a name="l00176"></a>00176   }
<a name="l00177"></a>00177 }
<a name="l00185"></a><a class="code" href="class_communication.html#a177161f8b437b0e406c301394a3632e5">00185</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">Communication::send</a>(byte messageId, <span class="keyword">const</span> <span class="keywordtype">int</span> params[], byte paramSize){
<a name="l00186"></a>00186   <span class="keywordflow">if</span>(messageId &gt; <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#ad398e1915b07ffc4091d4d5827bd6c6e">getMessageFilterLevel</a>()){
<a name="l00187"></a>00187     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(messageId);
<a name="l00188"></a>00188     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;-&quot;</span>);
<a name="l00189"></a>00189     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(paramSize);
<a name="l00190"></a>00190     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;:&quot;</span>);
<a name="l00191"></a>00191     byte i;
<a name="l00192"></a>00192     <span class="keywordflow">for</span>(i = 0; i &lt; (paramSize - 1); i++){
<a name="l00194"></a>00194       <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(params[i]);
<a name="l00195"></a>00195       <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.print(<span class="stringliteral">&quot;,&quot;</span>);
<a name="l00196"></a>00196     }
<a name="l00197"></a>00197     <span class="comment">//the last one is sent without a comma but with a new line</span>
<a name="l00198"></a>00198     <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.println(params[i]);
<a name="l00199"></a>00199   }
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201 
<a name="l00208"></a><a class="code" href="class_communication.html#acfbc09567d9cdc37fd1fc333f8b21d85">00208</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#acfbc09567d9cdc37fd1fc333f8b21d85">Communication::sendString</a>(<span class="keywordtype">char</span>* message){
<a name="l00209"></a>00209   <a class="code" href="_communication_8cpp.html#a03ede5fb0d1eb2158dbb5f2aeb7a5066">sc</a>.println(message);
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 
<a name="l00212"></a>00212 <span class="comment">/*</span>
<a name="l00213"></a>00213 <span class="comment"> * Gets the current configuration from the Configuraton instance and sends it over the serial port.</span>
<a name="l00214"></a>00214 <span class="comment"> */</span>
<a name="l00215"></a><a class="code" href="class_communication.html#a17e42ee6dbbaa353944d63e7d5dee25a">00215</a> <span class="keywordtype">void</span> <a class="code" href="class_communication.html#a17e42ee6dbbaa353944d63e7d5dee25a">Communication::sendCurrentConfiguration</a>(){
<a name="l00216"></a>00216   <span class="keywordtype">long</span> currentConfiguration[9];
<a name="l00217"></a>00217   <a class="code" href="class_communication.html#aa0bca76c6a5180371c2d2e9f978a33e9">_config</a>-&gt;<a class="code" href="class_configuration.html#a0b0009b5114b418831478c031372d12c">getCurrentConfiguration</a>(currentConfiguration);
<a name="l00218"></a>00218   <a class="code" href="class_communication.html#a8679b3cb7ceef5527faa24454ce0f18a">send</a>(204, currentConfiguration, 9);
<a name="l00219"></a>00219 }
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 
<a name="l00222"></a>00222 
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 
<a name="l00225"></a>00225 
<a name="l00226"></a>00226 
<a name="l00227"></a>00227 
<a name="l00228"></a>00228 
<a name="l00229"></a>00229 
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 
<a name="l00236"></a>00236 
<a name="l00237"></a>00237 
<a name="l00238"></a>00238 
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_communication_8cpp.html">Communication.cpp</a>      </li>

    <li class="footer">Generated on Tue Apr 3 2012 18:43:12 for prencar by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
   </ul>
 </div>


</body>
</html>
